import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export const useSearchStore = defineStore('search', () => {
    const search = ref(null)
    //返回token
    const searchInfo = computed(() => search.value);
    //更新token
    function updateSearch(s) {
        search.value = s;
    }
    //重置token
    function $reset() {
        search.value = null;
    }
    return {search,searchInfo,updateSearch,$reset};
},{
    persist:{
        key: 'search',
        storage: sessionStorage
    }
});
